package com.appkubes.mall.restful.application.goods.associate.dao;

import com.appkubes.mall.core.dao.BaseMallGoodsAssociateDao;
import com.appkubes.mall.core.entity.MallGoods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface GoodsAssociateDao extends BaseMallGoodsAssociateDao {

    @Select({"SELECT mg2.*",
            "FROM mall_goods mg",
            " JOIN mall_goods_associate mga ON mg.goods_key = mga.good_key",
            " JOIN mall_goods mg2 ON mga.associate_good_key = mg2.goods_key",
            " where mg.goods_key = #{goodsKey}"})
    List<MallGoods> selectAssociateGoods(@Param("goodsKey") String goodsKey);
}
